home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
oper_sys
/
quartz
/
quartz10.lha
/
src
/
runtime
/
interf.c
< prev
next >
Wrap
C/C++ Source or Header
|
1990-04-29
|
2KB
|
151 lines
/* Grubby interface to Presto -- don't compile with -pg */
#include <stdio.h>
#include <signal.h>
#include <parallel/microtask.h>
#include "thread.h"
#include "synch.h"
#include <usclkc.h>
#include "quartzcommon.h"
#include "profile.h"
#include "internal.h"
int QInit ()
{
usclk_init();
processGroup = getpgrp(0);
ProcessorListInit();
PrivProcessorInit(0);
ThreadpoolInit();
}
int QBegin (numProc, numProf, aff)
int numProc, numProf, aff;
{
numProcessors = numProc;
affinity = aff;
ProfileInit(numProf);
ProfileSetAllBusy();
MFork(ProfileStart, numProc, numProc + numProf, 0);
}
void QProcInit (id)
int id;
{
PrivProcessorInit(id);
}
int QIdleLoopBegin ()
{
ReplaceOnIdStack(IdleID, SpinState);
NowIdle();
SetProfileOn();
}
int QThreadStart (name, sched)
char *name;
int sched;
{
register IdStackEntry *s;
register Thread *t;
if (sched)
return(0);
SetStateOverhead();
ThreadAlloc(t);
ASSERT(t->type == ThreadType);
s = pP.thread->idStack.base - 1;
t->idStack.top = t->idStack.base - 1;
while (s < pP.thread->idStack.top)
(++(t->idStack.top))->procID = (++s)->procID & AllOffMask;
if (name)
{
t->p = SynchInit(name, VarThread);
TPushOnIdStack(t, t->p, (unsigned int)ReadyState);
t->p->thread = t; /* enable profiling of this thread */
}
else
t->p = NULL;
AddNominal();
TSetStateReady(t);
SetStateNormal();
return((int)t);
}
/* not used yet */
int QThreadReady (thr)
int thr;
{
register Thread *t = thr;
AddNominal();
TSetStateReady(t);
}
int QThreadIdle (thr)
int thr;
{
register Thread *t = thr;
pP.proc->curThread = pP.thread = pP.idleThread;
DecNominal();
NowIdle();
}
int QThreadRun (thr)
int thr;
{
register Thread *t = thr;
pP.proc->curThread = pP.thread = t;
NowBusy();
}
int QThreadRelease (thr)
int thr;
{
Thread *t = thr;
if (t != 0)
ThreadFree(t);
}
int QFinish ()
{
ProfileFinish();
}
int SLInit (name)
{
SpinLock *s;
if (!name)
return(0);
s = MyShmalloc(SpinLock, 1);
SpinLockInit(s, name);
return((int)s);
}
void SLLock (s)
{
if (s)
SpinLockAcquire((SpinLock *)s);
}
void SLUnlock (s)
{
if (s)
SpinLockRelease((SpinLock *)s);
}
void SLDispose (s)
{
if (s)
{
SpinLockDispose((SpinLock *)s);
shfree((char *)s);
}
}